package com.hmall.item.listen;

import com.hmall.item.constant.MqConstants;
import com.hmall.item.service.IItemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class ItemListener {

    @Autowired
    IItemService  iItemService;

    @RabbitListener(queues = MqConstants.ITEM_INSERT_QUEUE)
    public void listenInsertMsg(Integer id){
        log.info("接收到上架通知    id为{}" , id);
        iItemService.insert1(id);
    }

    @RabbitListener(queues = MqConstants.ITEM_DELETE_QUEUE)
    public void listenDeleteMsg(Integer id){
        log.info("接收到下架通知    id为{}" , id);
        iItemService.delete1(id);
    }
}
